from selenium import webdriver
import time
from webdriver_manager.chrome import ChromeDriverManager
# import logging
#
# logging.basicConfig(level=logging.DEBUG)

# 实例化浏览器驱动
driver = webdriver.Chrome(ChromeDriverManager().install())
# 打开百度页面
driver.get("https://www.baidu.com")

# 最大化浏览器
driver.maximize_window()
# # 获取浏览器尺寸
# print("当前浏览器尺寸为：", driver.get_window_size())
# time.sleep(2)
# # 设置浏览器尺寸
# driver.set_window_size(1000, 500)
# print("设置后浏览器尺寸为：", driver.get_window_size())

# # 获取浏览器位置
# print("浏览器当前位置为：", driver.get_window_position())
# time.sleep(2)
# # 设置浏览器位置
# driver.set_window_position(200, 100)
# print("设置后浏览器位置为：", driver.get_window_position())

# time.sleep(2)
# # 刷新页面
# driver.refresh()
# time.sleep(2)
# # 输入百度
# driver.find_element_by_id("kw").send_keys("坚果")
# time.sleep(2)
# # 点击-百度一下
# driver.find_element_by_id("su").click()
# time.sleep(2)
# # 回退
# driver.back()
# time.sleep(2)
# # 前进
# driver.forward()

# # 获取当前访问页面url
# print("当前url为：", driver.current_url)
# # 获取当前浏览器标题
# print("当前标题为：", driver.title)
# # 获取页面源码
# print("当前页面源码为：", driver.page_source)
# 截图
driver.get_screenshot_as_file("baidu.png")

time.sleep(5)
driver.quit()